package com.base.controller;

import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.base.comm.CommContent;
import com.base.po.voip.ShareLink;
import com.base.service.LogsService;
import com.base.service.ShareLinkService;
import com.base.utils.IP;

/**
 * 修改分享链接内容服务端
 * 
 * @author 
 *
 */
@Controller
@RequestMapping("/admin")
public class update_ShareLink {

	@Autowired
	private LogsService logsService;// log日志
	@Autowired
	private ShareLinkService shareLinkService; // 分享链接信息

	// 修改轮播信息
	@RequestMapping(value = "/toUpdateShareLink", method = RequestMethod.POST)
	public @ResponseBody int toUpdateShareLink(HttpServletRequest request, ShareLink sharelink)
			throws Exception {
		if (request.getSession().getAttribute("adminUserId") == null) return -1; // 未登录
		logsService.insert(CommContent.TYPE_UPDATE, CommContent.LOGS_UPDATE + "分享链接信息",
				(String) request.getSession().getAttribute("userNick"), true, IP.getIpAddr(request)); // 记录修改日志
		return shareLinkService.updateByPrimaryKeySelective(sharelink); // 修改
	}
}
